import { Controller, Get, Post, Body, Patch,Response, Param, Delete,UploadedFile,UseInterceptors, Query, Res } from '@nestjs/common';
import { UploadService } from './upload.service';
import { CreateUploadDto } from './dto/create-upload.dto';
import { UpdateUploadDto } from './dto/update-upload.dto';
import { FileInterceptor,FilesInterceptor } from '@nestjs/platform-express'
import { join } from 'path';

@Controller('upload')
export class UploadController {
  constructor(private readonly uploadService: UploadService) {}

  @Post('img')
  @UseInterceptors(FilesInterceptor('file'))
  uploadImg(@UploadedFile() file){
    console.log(file)
    return true
  }

  @Get('export')
  exportImage(@Response() res, @Query() query){
    // 逻辑...
    const baseUrl = join(__dirname,'../images/'+query.url)
    res.download(baseUrl)
  }
}
